#include <bits/stdc++.h>

using namespace std;

using ll = long long;

ll compute(ll x) {
	ll res = 0;
	for (int i = 0; i < 32; i++) {
		if (x == 0) break;
		res += x % 10;
		x /= 10;
	}
	return res;
}

int main() {
	int n;
	cin >> n;
	ll pre = 1;
	for (int i = 2; i <= n; i++) {
		ll a = pre;
		pre += compute(a);
	}
	cout << pre << endl;
	return 0;
}